Job Scheduler

ABSTRACT

A timer master can assign scheduled jobs to other application servers of a cluster. Leases for the timer master can be started in a lease table. The timer master can store job info for the scheduled jobs in a database. In case of a crash of the application server, another application server of the cluster can be assigned the time master and use the job information to assign scheduled jobs.

CLAIM OF PRIORITY

This application claims priority to U.S. Provisional Application No.60/747,364 entitled “Next Generation Clustering” filed May 16, 2006 andis hereby incorporated by reference. [Atty. Docket No. BEAS-01937US0]

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

BACKGROUND OF INVENTION

In order to handle a large number of interactions, enterprise softwareapplications can use application servers, such as J2EE applicationservers like the WebLogic Server™ available from BEA Systems, Inc., ofSan Jose, Calif. These application servers can be used in clusters thatcan interact with one another.

Some of the services of the application servers, called singletonservices should be run on only one application server of a cluster.These singleton services can include JMS servers, transaction recoveryservices or any other software that should be only run in a singleinstance.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows a database-based leasing system.

FIG. 2 shows a database-less leasing system of one embodiment of thepresent invention.

FIGS. 3A and 3B show a database-less leasing system of one embodiment ofthe present invention.

FIGS. 4A-4C illustrate an automatic migratable service system of oneembodiment of the present invention.

FIGS. 5A and 5B illustrate a job scheduler system.

DETAILED DESCRIPTION Database-Less Leasing

FIG. 1 shows an example of a leasing system using a database 102. Inthis example, application servers 104, 106 and 108 of the cluster 110can rely on the database to provide access to a lease table 102. Leasesat the lease table 102 can be used to indicate what application servershould run a singleton service. The leases can be updated by theapplication server running the singleton service. In case of a crash,the lease will no longer be updated and will become invalid. This canallow one of the application servers of the cluster 110 to take over fora crashed or partitioned application server that was controlling thelease system.

In some cases, it is desired to avoid the requirement of a HighAvailability (HA) database for leasing. Embodiments of the presentinvention comprise a database-less leasing system.

One embodiment of the present invention is a computer-implemented methodcomprising a cluster 202 of application servers 204, 206, 208 and 210.The method can include determining a cluster leader 202, using thecluster leader 212 to set up a lease table 214 at one of the applicationservers, and using the lease table 214 to maintain least one lease 216for a singleton service 218.

Since the lease table is stored at the application servers, no databaseis required. In one embodiment, copies of the lease table are maintainedat each application server in the cluster so that the copy of the leasetable is available in case of a crash or partition.

The lease tables can be used to allow automatic migration of thesingleton service. Node managers can be used to determine the state ofapplication servers in the cluster. The node manager can be a softwareprogram running on application server hosts. The node manager can beused to start and stop instances of the application servers.

The application server of the cluster that was started earliest can beselected to have the cluster leader. In one embodiment, the clusterleader is selected by a kind of competition. Every server in the clustercan periodically try to be the cluster leader. For example, every serverin the cluster can try to be the cluster leader once every 30 seconds.If the cluster leader already exists, their attempt is rejected. If thecluster leader currently does not exist, the first server to try toclaim it becomes cluster leader, thus preventing anyone else frombecoming cluster leader. In this way, the application server of thecluster that was started earliest can be selected to have the clusterleader. Alternately, the system can be designed such that a clusterleader could be selected by another method.

The cluster leader 212 can heartbeat other application servers of thecluster. The cluster leader 212 can store copies of the lease table inthe other application servers of the cluster 202 to operate in case of acrash or partition of one or more application servers. In oneembodiment, if the current cluster leader 212 fails to the heartbeat theother application servers, the other application servers can selectanother cluster leader.

One embodiment of the present invention comprises a cluster 202 of theapplication servers 204, 206, 208 and 210. A cluster leader is selectedbased on the first application server up. The cluster leader 212 is usedto set up a lease table 214 at one of the application servers 204.

One embodiment of the present invention comprises a computer-implementedsystem wherein a lease table 214 is maintained at an application server204 of a cluster 202 of application servers. Other application serversof the cluster can use the lease table 214 to maintain at least onelease 216 for a singleton service 218.

FIG. 3A shows a cluster leader heartbeating data to the otherapplication server of the cluster. FIG. 3B shows another cluster leaderbeing selected in the case of a crash of the application server havingthe current cluster leader. FIG. 3C shows another cluster leader beingselected in the case of a partition of the network that makes the firstapplication server unavailable.

Automatic Migratable Service

One embodiment of the present invention is a computer-implemented systemcomprising a first application server 402 of a cluster 404 that runs asingleton service 406. The first application server 102 maintaining alease 408 for the singleton service 406 at a lease table 410. Amigration master 412 checks the lease table 410 and reassigns thesingleton service 406 to a second application server 414 of a cluster404 if the first application server 402 fails to maintain the lease 408.The lease table 410 can be maintained in a database or by usingdatabase-less leasing as described above.

The first application server 402 can fail to update the lease because ofa crash of the first application server as shown in FIG. 4B or the firstapplication server 402 can fail to update the lease because the firstapplication server 402 is partitioned from the lease table as shown inFIG. 4C. The first application server 402 can heartbeat the lease 408 tomaintain control of the singleton service 406. The singleton service canbe a JMS server, a timer master or any other software that should be runin a single instance.

The second application server 414 can run a predetermined activationscript before getting the singleton service. The first applicationserver 402 can run a predetermined deactivation script after giving upthe singleton service. The migration master 412 can select the nextapplication server to run the singleton service, such as by selectingthe next application server.

In one embodiment, there can be a special rule if the singleton serviceis a Java Messaging System (JMS) service. If the singleton service is aJMS service, the migration manager can attempt a restart on the firstapplication server before any migration.

One embodiment is a computer implemented method or computer readablemedia containing code to do the steps of updating a lease 408 at a leasetable 410 for a singleton service. At first application server 402,checking the lease table 410 with a migration master 412. In addition,reassigning the singleton service 406 to a second application server ifthe first application server does not maintain the lease 408.

Job Scheduler

One embodiment of the present invention is a timer master 502 at anapplication server 504 of a cluster 506. The timer master 502 assignsscheduled jobs to other applications servers 508, 510 and 512 of thecluster. The application server 504 maintains a lease 514 for the timermaster from a lease table 516. The timer master 502 storing job info 520for the scheduled jobs in a database. In the case of a crash of theapplication server 504, another application server 510 of the cluster506 can be assigned the time master 502 which can use the job info toassign scheduled jobs.

The scheduled jobs can include reports, such as database reports. Suchreports can require a large number of database accesses and thus cantake a lot of system resources. The scheduled jobs can thus be scheduledto run at an off-peak time so as to not reduce the performance of otherapplications. The lease table can be in the database or alternately adatabase-less leasing system can be used. The timer master 502 can be asingleton service. The timer master 502 can be assigned to theapplication server 510 by a migration master. Other application serverscan request jobs from the timer master 502.

One embodiment of the present invention is a computer-implemented systemcomprising a timer master 502 at an application server 504 of a cluster.The timer master 502 can assign scheduled jobs to other applicationservers 508, 510 and 512 of the cluster 506. In the case of a crash ofthe application server 504, another application server 510 of thecluster 506 can be assigned the timer master that can assign scheduledjobs.

One embodiment of the present invention is an application server 504 ofa cluster 506 assigning scheduled jobs to other application servers ofthe cluster 504. In the case of a crash of the application server 504,assigning another application server 510 the timer master 502.Thereafter, scheduled jobs being assigned using the timer master 502 atthe other application server 510.

Detailed Description of Exemplary Embodiment

Details of one exemplary embodiment are described below. These detailsgive one example of how to implement the claimed invention and are notmeant to limit the scope of the invention or to narrow the scope of anyof the claimed terms.

Advanced clustering features like automatic server and servicemigration, cluster wide singleton and lock manager can use leasing andlease management. Leasing can guarantee that only one member in acluster gets ownership of the lease for a certain period of time thatcan be renewed. The lease owner is then able to execute certainprivileged operations like migrating failed servers knowing that it hasexclusive ownership of the lease. This specification describes howleasing and cluster master type of functionality can be implementedwithout any dependency on an external arbitrator like a highavailability database.

LeaseManagers can be used by subsystems to obtain leases, registerinterest in getting a lease when one becomes available, find out thecurrent owner of the lease etc. One type of leasing basis used forautomatic server migration requires the presence of a High Availability(HA) database. In other words, the lease table is always hosted in thedatabase and the database should be highly available for the cluster toquery and update the leases.

The lease table can be hosted in one of the servers in the cluster andnot in the database. This means that the cluster members can elect aserver that will host the lease table and become the cluster Leader.This elected cluster Leader can be responsible for giving out leases,updating the lease table and replicating the updates atomically to thecluster. Replication is important for failover purposes. If the clusterLeader becomes unavailable and does not send heartbeat to the groupasserting its presence, the members can start another round of voting toelect a new cluster master. The newly elected master can take ownershipof the lease table. Apart from taking ownership and hosting the leasetable, the cluster master owner can also perform automatic servermigration of failed cluster nodes.

In one embodiment, consensus based leasing can meet the followingrequirements:

-   -   1. There will be at most one cluster master at any given point        in time. This means that there will never be more than one        cluster master but there could be short periods where the        cluster is without a cluster master.    -   2. There will be short period just after the cluster startup        when there is no cluster master. The period could be in the        order of minutes.    -   3. When the current cluster master dies, the election of a new        cluster master can take time equal to the sum of:        -   1. heartbeat timeout (next poll time). This is the time            period during which the cluster members have not received            any heartbeat from the cluster master. By default this            period is 30 seconds.        -   2. Time taken by the algorithm to reach consensus.    -   4. Users can mark a subset of the cluster on which the cluster        on which the cluster master can be hoisted. This subset is        better suited for participating in consensus due to the presence        of redundant network connections and such. But this means that        if all the members in the consensus list die, then the cluster        will be without a cluster master. It is strongly recommended        that the consensus list be of separate machines.

Members of the cluster that can host the cluster master and participatein the consensus algorithm can be marked with a specialConsensusProcessIdentifier in the config.xml. This identifier can be aunique integer value. This can be an attributed on ServerMBean.Customers should just be able to mark the servers that can host thecluster master and the product should be able to generate theidentifiers automatically. There can be another attribute onClusterMBean that specifies the total number of consensus participants.In one embodiment, this attribute is called ConsensusParticipants. Itcan be the sum total of servers in a cluster that have theCunsensusProcessIdentifer.

Reaching an agreement on who is going to be the cluster leader can be atime consuming process. Once a cluster leader is elected, requests forleases can be arbitrated by the cluster master directly without goingthrough a round of consensus. The cluster leader will update the leasetable and replicate the updates to all other members in the consensuslist. This can be different from database leasing. In database leasing,all the leases including the lease for the cluster leader can bemaintained in the database as peers. In consensus leasing basis, thecluster leader lease can be used to grant other leases quickly.

It can be possible to choose the default leasing basis. Consensusleasing basis can be the default setting. Customers can override thedefault with the database leasing basis if they want to. A value, suchas ClusterMBean.setMigrationBasis( ), can control the default.

The console can allow customers to choose which cluster nodes can hostthe cluster master and automatically generate the consensus processidentifier. It can also set the valueClusterMBean.setConsensusParticipants( ) based on the number of serverschosen in the cluster.

The consensus leasing basis like all other implementations of theLeasingBasis interface can be hidden from subsystems and external users.Subsystems can ask for a singleton service by implementing theweblogic.cluster.singleton.SingletonService interface and thenregistering with a SingletonService Manager. LockManager can also beimplemented on top of leasing.

When a migratable service becomes unavailable for any reason (a bug inthe service code, server crashing, network partition) it can bedeactivated at its current location and activated on a new server.Should there be a failure while activating on the new server, it can bedeactivated on that server and migrated again. By default, we canattempt to start on every candidate server in the cluster until it haseither started or failed on every one. If it fails on every single one,it can log an error and leave it deactivated.

A service's liveness can be proven by the maintenance of a lease. Theserver that the service lives on can be responsible for keeping thelease alive, via a heartbeating mechanism. A server crash can naturallyresult in the lease timing out. In one embodiment, there is only onelease per Migratable Target. All services on that target can share thelease. In one embodiment, all services on a target can assumed to besomewhat dependent on each other. (Or at least, the user should tolerateone failing service on a target causing the entire target to migrate).In one embodiment, the admin server does not need to be active forautomatic migration.

The Migration Master (MM) can keep track of all services it is supposedto keep alive. The information can be available from the configuration.This is useful because if a service is unleased, then it will no longerexist in the table to be monitored. The configuration can be the sameacross all the services in the cluster.

Servers can be in Manager Service Independence (MSI) mode and stillparticipate in automatic migration. The only restriction is that newservices cannot be started. In one embodiment, if they are deployed to asingle server, without an admin server to distribute the configurationchange, the service will_not_be automatically migrated. When the adminserver starts and synchronizes everyone's configuration, migration canbe enabled for any newly added services (and can persist even if theadmin server is later shut down).

If the leases are lost (for example, network issues may cause the leasesto be lost), the server can deactivate its services. The MM can startthe service somewhere else. This may result in redundant deactivationcalls if the network connection is restored after deactivation butbefore MM notices the lease timeout, but deactivation is idempotent.

If the service is unhealthy yet not disconnected, it will communicate tothe Migratable Target and tell it to relinquish the lease. The MM willnotice the lease disappearing/timing out, and will migrate it.

The following method can be added to the MigratableTarget:

/** * Called by Migratable classes when they detect a failure and needto stop and start on a different server. Should only be used forunrecoverable failures in a Migratable object. If shutdownServer is true(as it would be for JTA), then the server will be shutdown and theservice deactivated as a consequence of this.*/public voidfailedService(String serviceName, boolean shutdownServer)

The handling of fencing can be difficult in the case of JTA. Should thedeactivation take a long time, there is no way of guaranteeing theservice will be deactivated by the time the next server tries toactivate it. In this case, if a graceful shutdown takes longer than thelease period, the server can immediately and abruptly exit. Its servicescan be taken over and recovered by the newly chosen home for themigratable services.

The Migration Master, upon noticing the expired lease, can start amigration. It can set a flag noting that the migration has begun forparticular service. This can prevent re-noticing an expired lease andmigrating again in the middle of a previous migration. (The samemechanism is used in Server migration.)

The current location of the service (if it is still available) candeactivate itself. Then the new location can call activate on thetarget. This can be the same code path as in the original migratableservices. There can be additional steps introduced, however.

When the target is being activated, its first action can be to claim thelease. This can stop the migration master from constantly checking forits liveness. It can also provide an atomicity lock on the operation; noone else can be activating while this one holds the lease.

Next, the service can check if a named Node Master (NM) pre-migrationscript is specified for it. Then it can check for the existence of thenode master on the current machine. If it is not there, but there is ascript specified, it can stop the migration. If it is there, it cancheck to see if the node master has performed a specified pre-migrationscript. If it hasn't run the script already, it can tell the node masterto run pre-migration script. Extra flags can be passed to this script,to allow the script to do something different if we're migrating JTA,JMS or something else entirely. Placeholder scripts, can be provided butspecific tlog migration, for example, need not be done.

In one embodiment, activation will not proceed until the node masterresponds positively that it has run the pre-migration script. We canmake repeated attempts to run the pre-migration script. If it cannot forsome reason, the migration will stop, and we will let the migrationmaster migrate us to a new server.

At this point, we can call the migratable services' activate( ) methodsin order. If they all run without exception, migration is now complete.

If there is an error during activation, we can stop and enterdeactivation mode.

Deactivation is essentially the inverse of activation. First, thedeactivating server can call deactivate on all the services in thespecified order. Exceptions will be logged, but no action can be taken.

Once all the services have had deactivate called, we will performanother node master check. The service will check if a named node masterpost-migration script is specified for it. Then it can check for theexistence of the node master on the current machine. If it is there,check to see if the node master has performed a specified post-migrationscript. If it hasn't run the script already, tell the node master to runthe post-migration script. Extra flags can be passed to this script, toallow the script to do something different if we're migrating JTA, JMSor something else entirely. In one embodiment, we can provideplaceholder scripts, but specific tlog migration, for example, cannot bedone.

If the post-migration script fails, a kill script will be run, ifavailable. If the kill script fails, activation can continue as normal.In the worst case, we can deactivate everywhere and let the adminreactivate it when the issues have been addressed. Finally, when thescript part is complete, the service will give up the lease. Scriptswill be run during manual migration, if specified.

In one embodiment, there is no automatic failback mechanism. The servicecan live in its new location forever, by default. Administrators maymanually migrate the target to a new (or, in the case of failback, old)server at any time in the same exact manner as they did before.

Should a service be migrated to every server and never come upsuccessfully, it can be left deactivated. Optional settings on theMigratableTargetMBean can control how many attempts to make in terms ofthe number of complete cluster loops. Note that existing migratabletarget limitations can still apply: if candidate servers are specified,only servers in the candidate server list will be tried.

The AdditionalMigrationAttempts can default to zero. It can control thenumber of times we will try to migrate the service across every serverin the cluster (or candidate-server list, if specified.) For example, ifa cluster has 3 members, and the AdditionalMigrationAttempts is set to2, we can try to start it on every server in the cluster, then pause,try again, pause, and try one final time. In this example, this meanseach server can have 3 opportunities to bring up the servicesuccessfully.

The pause between migration attempts can be controlled by a value, suchas MillisToSleepBetweenAttempts. In one embodiment, this ONLY controlsthe pause that happens when the service fails to come up on any server,so we start back at the first and try again. While doing normalmigrations there need be no delays.

<MigratableTarget  Cluster=“mycluster” ConstrainedCandidateServers=“server1,server2”  Name=“MIG-TAR-1” UserPreferredServer=“server1”  AdditionalMigrationAttempts=“2” MillisToSleepBetweenAttempts=“12000”  AutoMigratable=“true” />

The following methods can be added to the MigratableTargetMBean:

/*  * A migratable service could fail to come up on every possibleconfigured server. This attribute controls how many further attempts,after the service has failed on every server at least once, should betried. Note that each attempt specified here indicates another fullcircuit of migrations amongst all the configured servers. So for a3-server cluster, and a value of 2, a total of 4 additional migrationswill be attempted. (the original server is never a valid destination) */get/setAdditionalMigrationAttempts( ) /**  * Controls how long of apause there should be between the migration attempts described ingetAdditionalMigrationAttempts( ). Note that this delay only happenswhen the service has failed to come up on every server. It does notcause any sort of delay between attempts to migrate otherwise. */get/setMillisToSleepBetweenAttempts( )

JMS should be able to restart itself without undergoing an actualmigration (for performance purposes, doing a full migration would be awaste of time for the problem in question. For their purposes, a methodwill be added to MigrationManager that will request a service restartfor the named service, or a deactivation and reactivation on the sameserver; no resources released or acquired. Requests a ‘soft migration’.The specified migratable service will be deactivated and thenreactivated on the same server. Nodemanager scripts will NOT be invoked.Services that are dependent on this migratable will be restarted as wellrestartMigratable(Migratable m) Repeated, rapid restart attempts on oneserver will be interpreted as an error after a certain threshold is metand the target will be migrated. Since this is a method only designedfor internal use, external configuration of the threshold need not beprovided. Hidden get/set methods on ServerMBean can control how manyattempts can be made and how long the period is. (For example, it couldbe set to allow up to 3 restarts within a 12 hour period.) Controls howmany times a service may be restarted within the interval specified ingetIntervalForRestartAttemptThrottling. get/setAllowedRestartAttempts()Controls how long the interval is for throttling restart attempts. SeegetAllowedRestartAttempts. get/setIntervalForRestartAttemptThrottling( )

The Migration Master can be a service similar to a Cluster Master. Itcan be a lightweight singleton, stateless and maintained by leasecompetition, in the same manner as the Cluster Master. Each server canregister a permanent interest in obtaining the Migration Master lease.Whatever server currently holds it can perform the starting and stoppingof migration tasks. If the current Migration Master crashes or isshutdown, one of the waiting servers will be chosen by the leasinginfrastructure to take over the lease, becoming the new MigrationMaster. The Migration Master does not have to be collocated with theCluster Master.

The master migration can be the repository of migration information. Itcan keep records of all the migrations it has done (target name, sourceserver, destination server, timestamp). If the admin server isavailable, it can report migrations to the admin server forconsole/JMX/WLST display.

Non-debug level logging can be added to provide information to the userwhen migrations happen. Activation and Deactivation of a target on aserver can be logged. The current Migration Master can log the detailsof the migration: Source, Destination, Target Name, Time. It can alsolog whether or not each migration passed or failed. A failed migrationcan be logged as a warning, not an error. If a service cannot be startedon any server successfully, we will log an error.

There can be a new interface, SingletonService. MigratableTarget can bemodified to extend SingletonService. MigratableTarget can provideadditional functionality in the way of pre/post activation scriptsrequired for some of the current services that live onMigratableTargets. Note that the Migratable interface that some servicesmay implement is not a SingletonService. Migratable merely means a classcan be targeted to a MigratableTarget. It is the MigratableTarget itselfthat is actually operated upon by the code. MigratableTargets canstart/stop Migratable classes as appropriate, as they always have.

The SingletonService interface may be implemented by customers orinternal users looking for a lightweight cluster-wide singleton. It doesnot have as many features as the MigratableTarget (which will supportscripts, candidate machines, etc), but is much easier to configure andcreate.

A SingletonService can request immediate migration by calling deactivateon itself. The MM will notice the disappeared lease and will migrate theservice to a new location.

interface SingletonService /* * This is called upon server start andduring the activation stage of migrating. It should obtain any systemresources and start any services required for the SingletonService tobegin serving requests. */ public void activate( ) /* * This is calledupon server shutdown and during the deactivation stage of migration. Itshould release any resources obtained in activate, and stop any servicesthat should only be available from one provider in the cluster. */public void deactivate( )

The MigratableTargetMBean can have extra, optional attributes.PreScript, PostScript and AutoMigratable.

<MigratableTarget  Cluster=“mycluster” ConstrainedCandidateServers=“server1,server2”  Name=“MIG-TAR-1” UserPreferredServer=“server1” PreScript=“../scriptdir/runMeBeforeActivation” PostScript=“../scriptdir/runMeAfterDeactivation” KillScript=“../anotherscriptdir/runMeInCaseOfFailure” AutoMigratable=“true”  />

The following methods can be added to the MigratableTargetMBean

/**  * Sets the auto migratable value. If a Migratable Target isautomatically migratable, it will be migrated automatically upon theshutdown or failure of the server where it currently lives.  */get/setAutoMigratable( ) /**  * Sets the script to run before aMigratable Target is actually activated. Before the target is activated,if there is a script specified and NodeManager available, we will runthe script. Setting a script without a NodeManager available will resultin an error upon migration. If the script fails or cannot be found,migration will not proceed on the current server, and will be tried onthe next suitable server. (The next server in the candidate server list,or the cluster, if there is no candidate list.)  */get/setPreScriptFileName( ) /**  * Sets the script to run after aMigratable Target is fully deactivated. After the target is deactivated,if there is a script specified and NodeManager available, we will runthe script. Setting a script without a NodeManager available will resultin an error upon migration. If the script fails or cannot be found,migration will still proceed.  */ get/setPostScriptFileName( ) /**  *Sets the script to run in case a Migratable Target's post script fails.Setting a script without a NodeManager available will result in an errorupon migration. If the script fails or cannot be found, migration willstill proceed.  */ get/setKillScriptFileName( )

The console migratable target page can require an extra checkbox toallow enabling of automatic migration. PreScript and PostScript are notrequired, but will be executed if they exist. The console editing pagefor Migratable Targets can have these options settable there.

Multiple Migratable Services targeted to one Migratable Target canspecify the order of their activation, in case there are dependencies.Targets that are auto-migratable need not be ordered with respect toeach other. Service order will still be respected whether or not thetarget is automatically migratable or not.

Ordering need not be exposed to customers. The Migratable Targetinfrastructure in general is internal only.

Migratable services can be allowed to specify a deployment order intheir MBean. The behavior is modeled on deployment order. There can be avalue called ‘Order’ that accepts integers. (Including negative values.)When a target is asked to activate its component services, it can do soin order of smallest Order to largest Order. If no Order is specified, adefault value can be assigned. For consistency, this can be the samedefault that deployment order uses: 100. If two services have the sameOrder number, there is no guarantee of their order of activation withregards to each other.

When a target is asked to deactivate its component services, it can doso in order of largest Order to smallest Order. Note that if twoservices have the same Order number, their deactivation order is notguaranteed be the reverse of their Activation order.

Order can be a dynamic value. The current value of Order is always theone used. This means that if the Order changes between activation anddeactivation, the sequences may not be exact reverses of each other.

The case of a failed activation can follow the same rules as normalactivation and deactivation. Deactivation of the successfully activatedservices can happen in reverse order, unless Order numbers areidentical. In that case, the deactivation order may not be a reverse ofthe activation order.

The weblgoic.cluster.migration.Migratable interface can have thefollowing method added:

/** * Returns the order value for this particular migratable object.This controls in which order this object will be activated anddeactivated with regards to all the other migratable objects deployed ona migratable target. */ public int getOrder( )

The implementation and MBeans can be augmented with an additionalsetOrder method to allow user configuration of this value. This is NOTrequired, however. It is up to each individual implementor to decide ifthey want the order configurable.

A default order variable can be provided in the base interface:DEFAULT_ORDER. By default, all current implementing classes will returnit from the getOrder( ) call. This can assure that the current behaviorwill not be changed, until people make a specific effort to change theirorderings.

Job Scheduler can make the timers cluster aware and provides the abilityto execute them any where in the cluster. Timers are no longer tied tothe server that created them.

The purpose of this specification is to:

-   -   1. Make timescluster aware. Timers should be able to execute        anywhere in the cluster and failover as needed.    -   2. Provide cron job type of execution within the application        server cluster.

Users should be able to specify things like “execute this job repeatedlysomewhere in the cluster. The job should run if there is at least onerunning member in the cluster”. There is no dependency on the serverthat actually created the timer. The timer execution is load balancedacross the cluster and is able to failover to another running member incase of failures.

There can be two types of timers that can be differentiated based ontheir lifecycle.

Local Timer

-   -   A local timer can be scheduled within a server JAVA Virtual        Machine (JVM) and lives within the same JVM forever. The timer        runs as long as the JVM is alive and dies when the JVM exits.        The application needs to reschedule the timer on subsequent        server startup.

Cluster Wide Timers

-   -   A cluster wide timer can be aware of other server JVM's that        form part of the same cluster and is able to load balance and        failover. The timers lifecycle is not bound to the server that        created it but it is bound to the lifecycle of the cluster. As        long as at least one cluster member is alive the timer can be        able to execute. Such timers are able to survive a complete        cluster restart. Cluster wide timers are created and handled by        the Job Scheduler.

Each type can have its own advantages and disadvantages. Local timerscan handle fine grained periodicity in the order of milliseconds. Jobschedulers cannot handle fine grained periodicity with precision as thetimers need to be persisted. Cluster wide timers work well with coarsegrained intervals in the order of few seconds or more. Job scheduler canbe used to schedule jobs like running reports every day or at the end ofevery week. It cab be important to run the job even if the server thatcreated it is no longer available. Other cluster members can ensure thatthe job continues to execute.

Job Scheduler can meet the following requirements:

-   -   1. Use customer configured database to persist timers and make        them available to the entire cluster. Job Scheduler is dependent        on a database and cannot function without it. Oracle, DB2,        Informix, MySQL, Sybase, MSSQL are supported.    -   2. In one embodiment, the Job Scheduler will only work in a        cluster.    -   3. Submitted jobs can run anywhere in the cluster. Two        consecutive executions of a job can run on the same server or on        different servers. Only one server can execute the job at any        given point in time.    -   4. Job Scheduler is dependent on Leasing. Leasing support is        needed to elect the TimerMaster. Each server can also use        leasing to claim ownership on the job before executing it.    -   5. Job Scheduler can use the same leasing basis as Server        Migration and Singleton Services.    -   6. Job Scheduler can be bound into the global JNDI tree of each        server using a well defined name. The JNDI name can be        “weblogic.JobScheduler”. Users can cast the looked up object to        commonj.timers.TimerManager and use its methods to create jobs.    -   7. Only Serializable jobs are accepted by the Job Scheduler.        Non-Serializable jobs can be rejected with an        IllegalArgumentException.    -   8. ClusterMBean can expose an attribute called        DataSourceForJobScheduler that will be used to access the        database. In one embodiment, Job Scheduler functionality is only        available with the datasource is configured.    -   9. In one embodiment, Job Scheduler will only support schedule        at fixed delay functionality. Two consecutive job executions are        separated by an ‘interval’ period.    -   10. In one embodiment, only round-robin load balancing of jobs        is supported.

Every cluster member will periodically poll the TimerMaster (which isjust another cluster member) for ready jobs to execute. The TimerMasterwill give a fraction of the total ready jobs to each member forexecution.

Job Scheduler can require a database for persisting timers. Alldatabases supported by Server Migration functionality can be supportedby Job Scheduler as well. Job Scheduler can access the database usingClusterMBean.getDataSourceForJobScheduler( ). Users can create a tablecalled “weblogic_timers” with the following fields

Name Type TIMER_ID NUMBER TIMER_INFO VARCHAR2(100) TIMER_MANAGER_NAMEVARCHAR2(100) CLUSTER_NAME VARCHAR2(100) DOMAIN_NAME VARCHAR2(100)TIMER_LISTENER BLOB NEXT_EXECUTION_TIME NUMBER INTERVAL NUMBER

In one embodiment, the Job Scheduler only functions in a cluster. Allcluster nodes can participate in executing jobs without discrimination.In one embodiment, Job Scheduler will be turned on only if theDataSourceForJobScheduler ClusterMBean attribute is set to a valid datasource in config.xml. Here is an example:

<domain>   ...  <cluster>   <name>Cluster-0</name>  <multicast-address>239.192.0.0</multicast-address>  <multicast-port>7466</multicast-port>  <data-source-for-job-scheduler>JDBC Data  Source-0</data-source-for-job-scheduler>  </cluster>   ... <jdbc-system-resource>   <name>JDBC Data Source-0</name>  <target>myserver,server-0</target>  <descriptor-file-name>jdbc/JDBC_Data_Source-0-3407-jdbc.xml  </descriptor-file-name>  </jdbc-system-resource> </domain>

Job Scheduler can be looked up using the JNDI name“weblogic.JobScheduler” and cast to commonj.timers.TimerManager. Here isan example:

 InitialContext ic = new InitialContext( );  commonj.timers.TimerManagerjobScheduler = (common.timers.TimerManager)ic.lookup(“weblogic.JobScheduler”);  commonj.timers.TimerListenertimerListener =  new MySerializableTimerListener( ); jobScheduler.schedule(timerListener, 0, 30*1000); // execute this job every 30 seconds  ....  ....  private static classMySerializableTimerListener implements commonj.timers.TimerListener,java.io.Serializable {   public void timerExpired(Timer timer) { ... } }

Job scheduler can use leasing functionality to claim ownership ofindividual timers before execution and to select a Timer Master. TheTimer Master can be running on exactly one cluster member and isresponsible for allocating timers to individual servers. The leasingbasis can be dependent on the ClusterMBean.getLeasingBasis( ) attribute.If the LeasingBasis is set to database then the configuration associatedwith database leasing can be setup just like in Server Migration. If theLeasingBasis is set to “consensus” then no database support is requiredfor leasing.

Console can provide an option to setClusterMBean.setDataSourceForJobScheduler( ). The data source can beinherited from server migration or session persistence during shutdown.If customers configure data source for one they should be able to reuseit for Job Scheduler functionality as well.

One embodiment may be implemented using a conventional general purposeof a specialized digital computer or microprocessor(s) programmedaccording to the teachings of the present disclosure, as will beapparent to those skilled in the computer art. Appropriate softwarecoding can readily be prepared by skilled programmers based on theteachings of the present discloser, as will be apparent to those skilledin the software art. The invention may also be implemented by thepreparation of integrated circuits or by interconnecting an appropriatenetwork of conventional component circuits, as will be readily apparentto those skilled in the art.

One embodiment includes a computer program product which is a storagemedium (media) having instructions stored thereon/in which can be usedto program a computer to perform any of the features present herein. Thestorage medium can include, but is not limited to, any type of diskincluding floppy disks, optical discs, DVD, CD-ROMs, micro drive, andmagneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, flash memoryof media or device suitable for storing instructions and/or data storedon any one of the computer readable medium (media), the presentinvention can include software for controlling both the hardware of thegeneral purpose/specialized computer or microprocessor, and for enablingthe computer or microprocessor to interact with a human user or othermechanism utilizing the results of the present invention. Such softwaremay include, but is not limited to, device drivers, operating systems,execution environments/containers, and user applications.

Embodiments of the present invention can include providing code forimplementing processes of the present invention. The providing caninclude providing code to a user in any manner. For example, theproviding can include transmitting digital signals containing the codeto a user; providing the code on a physical media to a user; or anyother method of making the code available.

Embodiments of the present invention can include a computer implementedmethod for transmitting code which can be executed at a computer toperform any of the processes of embodiments of the present invention.The transmitting can include transfer through any portion of a network,such as the Internet; through wires, the atmosphere or space; or anyother type of transmission. The transmitting can include initiating atransmission of code; or causing the code to pass into any region orcountry from another region or country. For example, transmittingincludes causing the transfer of code through a portion of a network asa result of previously addressing and sending data including the code toa user. A transmission to a user can include any transmission receivedby the user in any region or country, regardless of the location fromwhich the transmission is sent.

Embodiments of the present invention can include a signal containingcode which can be executed at a computer to perform any of the processesof embodiments of the present invention. The signal can be transmittedthrough a network, such as the Internet; through wires, the atmosphereor space; or any other type of transmission. The entire signal need notbe in transit at the same time. The signal can extend in time over theperiod of its transfer. The signal is not to be considered as a snapshotof what is currently in transit.

The forgoing description of preferred embodiments of the presentinvention has been provided for the purposes of illustration anddescription. It is not intended to be exhaustive or to limit theinvention to the precise forms disclosed. Many modifications andvariations will be apparent to one of ordinary skill in the relevantarts. For example, steps preformed in the embodiments of the inventiondisclosed can be performed in alternate orders, certain steps can beomitted, and additional steps can be added. The embodiments where chosenand described in order to best explain the principles of the inventionand its practical application, thereby enabling others skilled in theart to understand the invention for various embodiments and with variousmodifications that are suited to the particular used contemplated. It isintended that the scope of the invention be defined by the claims andtheir equivalents.

1. A computer implemented system comprising: a timer master at anapplication server of a cluster, the timer master assigning scheduledjobs to other application servers of the cluster; the application servermaintaining a lease for the timer master from a lease table; the timermaster storing job information for the scheduled jobs on a database,wherein in case of a crash of the application server another applicationserver of the cluster is assigned the timer master and uses the jobinformation to assign scheduled jobs.
 2. The computer implemented systemof claim 1, wherein the scheduled jobs include reports.
 3. The computerimplemented system of claim 2, wherein the reports are database reports.4. The computer implemented system of claim 1, wherein the lease tableis in the database.
 5. The computer implemented system of claims 1,wherein the timer master is a singleton service.
 6. The computerimplemented system of claim 5, wherein the timer master is assigned toanother application server by a migration master.
 7. The computerimplemented system of claim 1, wherein the other application serversrequest jobs from the time master.
 8. The computer implemented system ofclaim 1, wherein the jobs are scheduled to run at an off-peak time.
 9. Acomputer implemented system comprising: a timer master at an applicationserver of a cluster, the timer master assigning scheduled jobs to otherapplication servers of the cluster; wherein in case of a crash of theapplication server, another application server of the cluster isassigned the timer master and assigns scheduled jobs.
 10. The computerimplemented system of claim 9, wherein the scheduled jobs includereports.
 11. The computer implemented system of claim 10, wherein thereports are database reports.
 12. The computer implemented system ofclaims 9, wherein the timer master maintains a lease in a lease table.13. The computer implemented system of claim 9, wherein the lease tableis in the database.
 14. The computer implemented system of claims 9,wherein the timer master is a singleton service.
 15. The computerimplemented system of claim 9, wherein the other application serversrequest tasks from the timer master.
 16. The computer implemented systemof claim 9, wherein the other application servers request jobs from thetimer master.
 17. The computer implemented system of claim 9, whereinthe jobs are scheduled to run at an off-peak time.
 18. The computerimplemented system of claims 9, wherein the timer master stores job infoin a database.
 19. The computer implemented method comprising: Using atimer master at an application server of a cluster, assigning scheduledjobs to other application servers of the cluster; in case of a crash ofthe application server, assigning another application server the timermaster; and thereafter, assigning scheduled jobs using the timer masterat the other applicant server.
 20. The computer implemented method ofclaim 18, wherein the scheduled jobs include reports.
 21. The computerimplemented method of claims 18, wherein the timer master is a singletonservice.
 22. The computer implemented method of claim 21, wherein thetimer master is assigned to another application server by a migrationmaster.
 23. The computer implemented method of claim 18, wherein theother application servers request jobs from the timer master.